{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#第二题  创建第一个视觉程序“Hello，world！”，显示Lena图片。具体效果参看课程PPT。 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "49"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "mt = cv2.imread(\"./lena.jpg\")\n",
    "cv2.imshow(\"lena\",mt)\n",
    "cv2.waitKey()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#第三题 对Lena图像，分解得到RGB分量及HSV分量，显示各分量，并对结果进行比较说明。 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2\n",
    "mt = cv2.imread(\"./lena.jpg\")\n",
    "print(\"----0------\")\n",
    "# cv2.imshow(\"lena\",mt)\n",
    "bgr =cv2.split(mt)\n",
    "\n",
    "cv2.imshow(\"lena_b\",bgr[0])\n",
    "cv2.imshow(\"lena_g\",bgr[1])\n",
    "cv2.imshow(\"lena_r\",bgr[2])\n",
    "\n",
    "hsv = cv2.cvtColor(mt,cv2.COLOR_BGR2HSV)\n",
    "cv2.imshow(\"lena_h\",hsv[:,:,0])\n",
    "cv2.imshow(\"lena_s\",hsv[:,:,1])\n",
    "cv2.imshow(\"lena_v\",hsv[:,:,2])\n",
    "cv2.waitKey()\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "RGB 通道分离结果图片如下\n",
    "原图<br>\n",
    "![jupyter](./lena.jpg)<br>\n",
    "<font size=5>蓝色分量<br>\n",
    "![jupyter](./lena_b.bmp)<br>\n",
    "<font size=5>绿色分量<br>\n",
    "![jupyter](./lena_g.bmp)<br>\n",
    "<font size=5>红色分量<br>\n",
    "![jupyter](./lena_r.bmp)<br>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
